﻿<UserControl  
    x:Class="ibba.src.noriskbo.PainelListaGarantidores"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:ibba.src.noriskbo.ViewModels"
    xmlns:slc="clr-namespace:ibba.src.sl.componentes;assembly=ibba.src.sl.componentes"
    xmlns:slrv="clr-namespace:ibba.src.sl.recursos.Validations;assembly=ibba.src.sl.recursos"
    mc:Ignorable="d"
    d:DesignWidth="400" d:DesignHeight="300">

    <UserControl.Resources>
        <slc:SwitchConverter x:Key="LabelDocConverter" 
                             Else="CNPJ:">
            <slc:SwitchCase When="F" Then="CPF:" />
        </slc:SwitchConverter>
        <slc:SwitchConverter x:Key="CheckExcluirConverter" 
                             Else="{StaticResource IconeDeleteGray}">
            <slc:SwitchCase When="3" Then="{StaticResource IconeRemover}" />
        </slc:SwitchConverter>
        <slc:SwitchConverter x:Key="OpacityDeleteConverter" 
                             Else="1">
            <slc:SwitchCase When="3" Then="0.30" />
        </slc:SwitchConverter>

        <slc:SwitchConverter x:Key="ImgFlagAcaoSQLConverter" 
                             Else="{x:Null}">
            <slc:SwitchCase When="1" Then="{StaticResource IconeFlagAP}" />
            <slc:SwitchCase When="2" Then="{StaticResource IconeFlagEA}" />
            <slc:SwitchCase When="99" Then="{StaticResource IconeFlagEE}" />
        </slc:SwitchConverter>
        
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="{x:Null}"> 

        <StackPanel Orientation="Horizontal">

            <Grid x:Name="gridContent">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                </Grid.RowDefinitions>

                <!--<Border Grid.Row="0" Background="{StaticResource BlueStrong}" BorderBrush="#FFB5B6B5" BorderThickness="1" CornerRadius="8,8,0,0">-->
                    <Grid Grid.Row="0" Margin="1,0">
                    <Border Margin="0" CornerRadius="5,5,0,0" Background="{StaticResource BlueHeaderColorPrimary}" >

                            <Border Margin="0,0,0,0" CornerRadius="8,8,0,0" >
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="1,0" EndPoint="0.569,1.451">
                                        <LinearGradientBrush.GradientStops>
                                            <GradientStopCollection>
                                                <GradientStop Offset="0.200" Color="{StaticResource BlueHeaderColorGradient1}" />
                                                <GradientStop Offset="0.977" Color="{StaticResource BlueHeaderColorGradient2}" />
                                            </GradientStopCollection>
                                        </LinearGradientBrush.GradientStops>
                                    </LinearGradientBrush>
                                </Border.Background>

                                <Border Margin="-1">
                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0.505,-0.117" EndPoint="0.505,1.176">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStopCollection>
                                                    <GradientStop Offset="0" Color="{StaticResource BlueHeaderColorGradient3}" />
                                                    <GradientStop Offset="0.972" Color="{StaticResource BlueHeaderColorGradient4}" />
                                                </GradientStopCollection>
                                            </LinearGradientBrush.GradientStops>
                                        </LinearGradientBrush>
                                    </Border.Background>

                                    <Path Width="50" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" 
                                          Data="M 527,265 C527,265 527,245 527,245 527,243 525,240 522,240 522,240 500,240 500,240 500,240 527,265 527,265 z" 
                                          Opacity="0.690" Stretch="Fill">
                                        <Path.Fill>
                                            <LinearGradientBrush StartPoint="0.925,0.04" EndPoint="0.424,0.519">
                                                <LinearGradientBrush.GradientStops>
                                                    <GradientStopCollection>
                                                        <GradientStop Offset="0" Color="#8cffffff" />
                                                        <GradientStop Offset="0.966" Color="#44ffffff" />
                                                    </GradientStopCollection>
                                                </LinearGradientBrush.GradientStops>
                                            </LinearGradientBrush>
                                        </Path.Fill>
                                    </Path>
                                </Border>

                            </Border>
                        </Border>
                        
                        <TextBlock Text="Garantidores" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0"/>
                        
                        <Button x:Name="btnMinimizar" Width="20" Height="20"
                                HorizontalAlignment="Right" VerticalAlignment="Center"
                                ToolTipService.ToolTip="Minimizar Listagem" Margin="4" Click="btnMinimizar_Click">
                            <Image Source="{StaticResource BotaoProximo}" />
                        </Button>
                    </Grid>
                <!--</Border>-->

                <Border Grid.Row="1" BorderThickness="1" BorderBrush="#FF6B696B" Background="#FFDFE8EB" Padding="5">
                    <ContentControl IsEnabled="{Binding HabilitarInclusaoGarantidor}">
                        <Grid>
                            <StackPanel Orientation="Vertical">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Garantidor" Width="250" Foreground="DimGray" />
                                    <TextBlock Text=" %" Margin="3,0,0,0" Foreground="DimGray" FontFamily="Arial Black" />
                                </StackPanel>

                                <StackPanel Orientation="Horizontal">
                                    <sdk:AutoCompleteBox x:Name="txtAddGarantidor" Width="250" 
                                                         IsTextCompletionEnabled="True" MinimumPrefixLength="2"
                                                         ValueMemberPath="NomeCliente"
                                                         ItemTemplate="{StaticResource DataTemplateCliente}"
                                                         KeyUp="txtAddGarantidor_KeyUp">
                                        <!--<sdk:AutoCompleteBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Vertical" MinWidth="250" Margin="0,2,20,2">
                                                    <TextBlock Text="{Binding Path=NomeCliente}" />

                                                    <StackPanel Orientation="Vertical" HorizontalAlignment="Right">
                                                        <TextBlock FontSize="9" Foreground="Gray" HorizontalAlignment="Right">
                                                            <Run Text="Id: " Foreground="Black"/>
                                                            <Run Text="{Binding Path=IdCliente}" />
                                                        </TextBlock>
                                                        <TextBlock FontSize="9" Foreground="Gray" HorizontalAlignment="Right"
                                                                   Text="{Binding Path=FormatCPFouCNPJ}"/>
                                                    </StackPanel>
                                                </StackPanel>
                                            </DataTemplate>
                                        </sdk:AutoCompleteBox.ItemTemplate>-->
                                    </sdk:AutoCompleteBox>

                                    <TextBox x:Name="txtAddPercentual" Width="35" MaxLength="3" Margin="3,0,0,0" slrv:TextBoxFilterService.Filter="PositiveInteger"/>

                                    <Button x:Name="btnAddGarantidor" BorderBrush="#FFADAAAD" BorderThickness="0"
                                            HorizontalAlignment="Right" Width="20" Height="20" Margin="3,2,2,2"
                                            Click="btnAddGarantidor_Click">
                                        <Image Source="{StaticResource IconeAdicionar}" />
                                    </Button>
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </ContentControl>
                </Border>

                <Border Grid.Row="2" Background="#FFEFEFEF" BorderBrush="#FFB5B6B5" BorderThickness="1,0" Padding="5">
                    <Border BorderBrush="#FFDBD8D8" BorderThickness="1" Padding="0" Background="White" CornerRadius="3">
                        
                        <ListBox BorderBrush="#FF6B696B" Background="White" BorderThickness="0"
                                 ItemsSource="{Binding DetalheGarantidores.ListaOC}"
                                 SelectedItem="{Binding DetalheGarantidores.DetalheSelecionado, Mode=TwoWay}">
                            <!--<ListBoxItem>-->
                            <ListBox.ItemTemplate>
                                <DataTemplate>

                                    <Grid Margin="1" >
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        
                                        <!--<TextBlock Grid.RowSpan="3" Style="{StaticResource TitlePage}" Margin="0,-3,0,0" FontSize="36" FontFamily="Arial Black" 
                                                   Text="{Binding IdGarantidor}"/>-->

                                        <Border Grid.Row="2" Grid.ColumnSpan="2" 
                                                Style="{StaticResource LineBlue}" 
                                                Width="300" Margin="0,5" HorizontalAlignment="Center"/>

                                        <StackPanel Orientation="Horizontal" Grid.Row="0" Opacity="{Binding FlagAcaoSQL, Converter={StaticResource OpacityDeleteConverter}}">
                                            <TextBlock Width="270" Text="{Binding Nome, FallbackValue=Nonononon}" Height="16" />
                                        </StackPanel>

                                        <Grid Grid.Row="1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>

                                            <StackPanel Orientation="Horizontal" Grid.Row="1" Opacity="{Binding FlagAcaoSQL, Converter={StaticResource OpacityDeleteConverter}}">
                                                <Image Source="{Binding IndexImageFlag, Converter={StaticResource ImgFlagAcaoSQLConverter}}" 
                                                       Width="10" HorizontalAlignment="Left" VerticalAlignment="Top" />

                                                <StackPanel Orientation="Vertical" Grid.Row="1" Margin="3,0,0,0">
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Text="ID:" Width="40" Foreground="DimGray" VerticalAlignment="Center"/>
                                                        <TextBlock Text="{Binding IdPessoa}" Foreground="Black"/>
                                                    </StackPanel>
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Width="40" Foreground="DimGray" VerticalAlignment="Center"
                                                               Text="{Binding TipoPessoa, Converter={StaticResource LabelDocConverter}, FallbackValue=CNPJ:}"/>
                                                        <TextBlock Text="{Binding FormatCPFouCNPJ}" Foreground="Black"/>
                                                    </StackPanel>
                                                </StackPanel>
                                            </StackPanel>
                                            
                                            <StackPanel Orientation="Horizontal" Grid.Column="1" Opacity="{Binding FlagAcaoSQL, Converter={StaticResource OpacityDeleteConverter}}">
                                                <Border Style="{StaticResource LineGold}" Width="1" Height="42" Margin="3,0" 
                                                        VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                <StackPanel Orientation="Vertical">
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock FontFamily="Arial Black" FontSize="28" Width="56" Margin="0,-8,0,0" 
                                                             HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Right"                                                          
                                                             Text="{Binding PercentualGarantidor, Mode=TwoWay, StringFormat=\{0:n0\}, FallbackValue=100}" />
                                                        <TextBlock Text="%" VerticalAlignment="Top" FontSize="12" FontFamily="Arial Black"/>
                                                    </StackPanel>
                                                    <TextBlock Text="garantido" Foreground="DimGray" Margin="0,-10,0,0"
                                                               VerticalAlignment="Top" HorizontalAlignment="Center"/>
                                                </StackPanel>
                                            </StackPanel>

                                            <Grid HorizontalAlignment="Right" Margin="0,-15,0,0" Grid.Column="1" VerticalAlignment="Top" Height="13" Width="13" Opacity="1">
                                                <Image Name="imgExcluirGarantidor" Source="{Binding FlagAcaoSQL, Converter={StaticResource CheckExcluirConverter}}" 
                                                   Cursor="Hand" HorizontalAlignment="Right" Width="13" ToolTipService.ToolTip="Marcar para excluir!" 
                                                   MouseLeftButtonUp="imgExcluirGarantidor_MouseLeftButtonUp" Opacity="1"/>
                                            </Grid>
                                        </Grid>

                                    </Grid>

                                </DataTemplate>
                            </ListBox.ItemTemplate>
                            <!--</ListBoxItem>-->
                        </ListBox>
                    </Border>
                </Border>
            </Grid>

            <Border BorderThickness="1,1,1,1" BorderBrush="{StaticResource BlueOpaco}" Background="#FFEFEFEF" CornerRadius="0,8,0,0"
                    Visibility="{Binding ElementName=gridContent, Path=Visibility, Converter={StaticResource NotVisibilityConverter}}">

                <Grid>
                    <Button x:Name="btnMaximizar" Width="20" Height="20"
                            VerticalAlignment="Top" Margin="3,5,3,0"
                            ToolTipService.ToolTip="Exibir Listagem"
                            Click="btnMaximizar_Click">
                        <Image Source="{StaticResource BotaoAnterior}" />
                    </Button>
                    <sdk:Label Content="{Binding RegistroSelecionado.Garantidores.Count, FallbackValue=0}" Style="{StaticResource LegendBlue}" Margin="2,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Right" />
                    <TextBlock Text="Garantidores" Style="{StaticResource Rotate90}" FontSize="16" Foreground="DimGray" Margin="2,150,-78,0" 
                               VerticalAlignment="Top" HorizontalAlignment="Center" />
                </Grid>
            </Border>
            
        </StackPanel>

    </Grid>
</UserControl>